cmake_minimum_required(VERSION 3.16)
project(Smart_Sell VERSION 1.0.0 LANGUAGES CXX)

# 设置C++标准
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED ON)

# 设置Qt路径
set(CMAKE_PREFIX_PATH "D:/qt/qt5.14.2/5.14.2/mingw73_64")

# 查找Qt5组件
find_package(Qt5 REQUIRED COMPONENTS Core Widgets Sql)

# 启用Qt的MOC、UIC和RCC
set(CMAKE_AUTOMOC ON)
set(CMAKE_AUTOUIC ON)
set(CMAKE_AUTORCC ON)

# 设置UI文件搜索路径
set(CMAKE_AUTOUIC_SEARCH_PATHS ${CMAKE_CURRENT_SOURCE_DIR}/ui)

# 源文件
set(SOURCES
    src/main.cpp
    src/loginwindow.cpp
    src/mainwindow.cpp
    src/monitorwindow.cpp
    src/databasewindow.cpp
)

# 头文件
set(HEADERS
    src/loginwindow.h
    src/mainwindow.h
    src/monitorwindow.h
    src/databasewindow.h
)

# UI文件
set(UI_FILES
    ui/loginwindow.ui
    ui/mainwindow.ui
    ui/monitorwindow.ui
    ui/databasewindow.ui
)

# 创建可执行文件
add_executable(Smart_Sell
    ${SOURCES}
    ${HEADERS}
    ${UI_FILES}
)

# 链接Qt库
target_link_libraries(Smart_Sell
    Qt5::Core
    Qt5::Widgets
    Qt5::Sql
)

# 设置输出目录
set_target_properties(Smart_Sell PROPERTIES
    RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin
)

# Windows特定设置
if(WIN32)
    set_target_properties(Smart_Sell PROPERTIES
        WIN32_EXECUTABLE TRUE
    )
endif()